﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DBLGen.UI.Design.Query
{
	public sealed class SqlOperand
	{
		public static string GetSQLOperand(Operand o)
		{
			switch (o)
			{
				case Operand.Equal:
					return " = ";
				case Operand.NotEqual:
					return " <> ";
				case Operand.GreaterThan:
					return " > ";
				case Operand.GreaterThanOrEqual:
					return " >= ";
				case Operand.LessThan:
					return " < ";
				case Operand.LessThanOrEqual:
					return " <= ";
				case Operand.Like:
					return " LIKE ";
				case Operand.IsNull:
					return " IS NULL ";
				case Operand.IsNotNull:
					return " IS NOT NULL ";
				//case Operand.Between:
				//  return " > ";
				//  break;
				//case Operand.In:
				//  return " IN ( {0} ) ";
				//case Operand.NotIn:
				//  return " NOT IN ( {0} ) ";
				case Operand.NotLike:
					return " NOT LIKE ";
			}
			return " = ";
		}
	}


	public enum Operand
	{
		/// <summary>
		/// Equal Comparison
		/// </summary>
		Equal = 1,
		/// <summary>
		/// Not Equal Comparison
		/// </summary>
		NotEqual,
		/// <summary>
		/// Greater Than Comparison
		/// </summary>
		GreaterThan,
		/// <summary>
		/// Greater Than or Equal Comparison
		/// </summary>
		GreaterThanOrEqual,
		/// <summary>
		/// Less Than Comparison
		/// </summary>
		LessThan,
		/// <summary>
		/// Less Than or Equal Comparison
		/// </summary>
		LessThanOrEqual,
		/// <summary>
		/// Like Comparison, "%s%" does it have an 's' in it? "s%" does it begin with 's'?
		/// </summary>
		Like,
		/// <summary>
		/// Is the value null in the database
		/// </summary>
		IsNull,
		/// <summary>
		/// Is the value non-null in the database
		/// </summary>
		IsNotNull,
		/// <summary>
		/// Is the value between two parameters? see <see cref="BetweenBeginValue"/> and <see cref="BetweenEndValue"/>. 
		/// Note that Between can be for other data types than just dates.
		/// </summary>
		Between,
		/// <summary>
		/// Is the value in a list, ie, "4,5,6,7,8"
		/// </summary>
		In,
		/// <summary>
		/// NOT in a list, ie not in, "4,5,6,7,8"
		/// </summary>
		NotIn,
		/// <summary>
		/// Not Like Comparison, "%s%", anything that does not it have an 's' in it.
		/// </summary>
		NotLike
	};
}
